<template>
	<view class="mainpadding_top">
		<!-- 支付宝 -->
		<template v-if="type==1">
			<view class="xiahuaxian flexbetween">
				<view class="xiaohei ershiba fonweight">支付宝账号</view>
				<view class="xiaohui ershiba">{{userInfo.ali_account}}</view>
			</view>
		</template>
		<!-- 微信 -->
		<template v-if="type==2">
			<view class="xiahuaxian flexbetween">
				<view class="xiaohei ershiba fonweight">微信号</view>
				<view class="xiaohui ershiba">{{userInfo.wechat_account}}</view>
			</view>
		</template>
		<!-- 银行卡 -->
		<template v-if="type==3">
			<view class="xiahuaxian flexbetween">
				<view class="xiaohei ershiba fonweight">开户行</view>
				<view class="xiaohui ershiba">{{userInfo.openbank}}</view>
			</view>
			<view class="xiahuaxian flexbetween margin_top">
				<view class="xiaohei ershiba fonweight">银行卡号</view>
				<view class="xiaohui ershiba">{{userInfo.bankno}}</view>
			</view>
			<view class="xiahuaxian flexbetween margin_top">
				<view class="xiaohei ershiba fonweight">手机号</view>
				<view class="xiaohui ershiba">{{userInfo.bankmobile}}</view>
			</view>
		</template>
		<view class="xiaohei ershiba margin_top fonweight">提现金额</view>
		<view class="margin_top6 flexbetween xiahuaxian">
			<view class="flexleft">
				<text class="xiaohei bigtext fonweight margin_top1 margin_right2">￥</text>
				<input type="digit" placeholder="请输入金额" class="" style="font-size: 45rpx;" v-model="tx_price"/>
			</view>
			<view class="huanbtn flexcenter" @click="tx_price = userInfo.bzj_price">全部提现</view>
		</view>
		<view class="margin_top flexleft">
			<u-icon name="info-circle-fill" class="margin_right1" color="#b99649" size="20" @click="flag=2;bshow=true"></u-icon>
			<view class="xiaohei ershiba fonweight">最低提现金额为￥{{withdrawal_price}}，当前可提现<text style="color: #b99649;">￥{{userInfo.sy_bzj_price}}</text></view>
		</view>
		<view class="bigbtn margin_top6" @click="submit">立即提现</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				type:1,//1支付宝，2微信，3银行卡
				userInfo:{},
				tx_price:"",
				withdrawal_price:""
			}
		},
		onLoad(options) {
			this.type = options.type
			this.init()
			this.getsystem()
		},
		methods: {
			getsystem() {
				httpRequest.request('/api/index/getConfigInfoItem', 'GET', {
					pidtype: "withdrawalset",
					type: "withdrawal_price",
				}).then(res => {
					this.withdrawal_price = res.data
				})
			},
			init() {
				uni.showLoading({
					mask:true,
					title:"请稍后"
				})
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					uni.hideLoading()
					if (res.code == 1) {
						this.userInfo = res.data
					} else {
						this.userInfo = null
					}
				})
			},
			submit(){
				if(Number(this.userInfo.bzj_price)<Number(this.tx_price)){
					httpRequest.toast("提现金额不能大于可提现金额")
					return false
				}
				httpRequest.request('/api/user/addWithdrawal', 'GET', {
					type:this.type==1?2:(this.type==2?1:this.type),
					withdrawal_price:this.tx_price
				}).then(res => {
					httpRequest.toast(res.msg)
					if (res.code == 1) {
						setTimeout(()=>{
							uni.navigateBack({
								delta:2
							})
						},1000)
					} 
				})
				
			},
		}
	}
</script>

<style>
.huanbtn {
		width: 180rpx;
		height: 60rpx;
		background-color: #fdf9f0;
		font-weight: 400;
		font-size: 28rpx;
		color: #BA9549;
	}
</style>
